import java.util.HashSet;
import java.util.Set;

public class ToArrayExample {


    public static void main(String[] args) {
        Set<String> set1 = new HashSet<>();
        set1.add("apple");
        set1.add("banana");

        Set<String> set2 = new HashSet<>();
        set2.add("banana");
        set2.add("cherry");

        set1.addAll(set2);
        System.out.println("添加元素后的 set1: " + set1); // [banana, apple, cherry]
    }







    public static void main1(String[] args) {
        Set<String> set1 = new HashSet<>();
        set1.add("apple");
        set1.add("banana");
        set1.add("cherry");

        Set<String> set2 = new HashSet<>();
        set2.add("apple");
        set2.add("banana");

        boolean result = set1.containsAll(set2);
        System.out.println("set1 是否包含 set2 中的所有元素: " + result); //true
    }




    public static void main0(String[] args) {

        Set<Integer> set1 = new HashSet<>();
        set1.add(5);
        set1.add(20);
        set1.add(15);
        set1.add(8);

        Integer[] toArray = set1.toArray(new Integer[0]);

        for (Integer a : toArray) {
            System.out.print(a + " ");
        }

        System.out.println(); // 20 5 8 15

    }
}